﻿using System.Data.Entity.Core;
using System.Data.Entity.Infrastructure;
using System.Data.SqlClient;

namespace Kairos
{
    public static class ExceptionHandling
    {
        public static bool HandlesSqlExceptionNumber547(DbUpdateException ex)
        {
            var innerUpdateException = ex.InnerException as UpdateException;

            if (innerUpdateException == null)
                return false;

            var innerSqlException = innerUpdateException.InnerException as SqlException;

            if (innerSqlException == null)
                return false;

            if (innerSqlException.Number != 547)
                return false;

            return true;
        }
    }
}